// 用于主页面通用内容
import Main from '@/views/Main.vue';
import RouterView from '@/views/router-view.vue';
/*
 * meta 参数说明
 * @params    string    title    页面标题
 * @params    boolean    cache    是否通过router-view的keep-alive缓存页面
 * @params    boolean access    权限，需自行写相关业务逻辑
 * @params    boolean divider 用于二级菜单时是否显示分割线，仅为false时生效
 * @params    string    active    用于菜单显示重新指向对应的节点
 * 
 */

/*
 * unLoginRouter 说明
 * 1.未登录状态下可访问的独立页面
 * 
 */
export const unLoginRouter = [
    {
        path: '/login',
        name: 'login',
        meta: {
            title: '登录'    
        },
        component: resolve => {
            require(['@/views/login/login.vue'], resolve)
        }
    },
    {
        path: '/404',
        name: 'error-404',
        meta: {
            title: '404 页面不存在'
        },
        component: resolve => {
            require(['@/views/error-page/404.vue'], resolve)
        }
    }
]

/*
 * simpleRouter 简单路由说明
 * 1.登录状态下可访问的独立页面
 * 
 */
export const simpleRouter = [
    /* {
        path: '/demo',
        name: 'demo',
        meta: {
            title: 'DEMO页面'
        },
        component: resolve => {
            require(['@/views/demo.vue'], resolve)
        }
    } */
]

/*
 * mainRouter 说明
 * 1.需登录后才可访问的路由
 * 2.需要通过main通用组件显示的路由
 * 3.不需要在主菜单显示的路由
 * 
 */
export const mainRouter = {
    path: '/',
    name: 'mainRouter',
    redirect: '/home',        // 将/重置到/home主页
    component: Main,
    children: [
        
    ]
}

/*
 * appRouter 说明
 * 1.需登录后才可访问的路由
 * 2.需要通过main通用组件显示的路由
 * 3.需要展示在主菜单里的路由，支持多级，3级及以上的路由需要通过RouterView来加载
 * 
 */
export const appRouter = [
    // 如果首页不需要展示在主菜单里，可放在mainRouter里
    {
        path: '/overall',
        name: 'home',
        redirect: '/overall/index',
        meta: {
            title: '全局',
            icon: 'ios-analytics'
        },
        component: Main,
        children: [
            {
                path: 'index',
                name: 'home_index',
                meta: {
                    title: '全局'
                },
                component: resolve => {
                    require(['@/views/home/index.vue'], resolve)
                }
            },
            
        ]
    },
    {
        path: '/project',
        name: 'project',
        redirect: '/project/list',
        meta: {
            title: '项目',
            icon: 'md-cube'
        },
        component: Main,
        children: [
            {
                path: 'list',
                name: 'project_list',
                redirect: '/project/project/index',
                meta: {
                    title: '项目列表'
                },
                component: RouterView,
                children: [
                    {
                        path: 'index',
                        name: 'project_index',
                        meta: {
                            title: '项目列表'
                        },
                        component: resolve => {
                            require(['@/views/project/project/index.vue'], resolve)
                        }
                    },
                    {
                        path: 'edit',
                        name: 'project_edit',
                        meta: {
                            title: '项目编辑'
                        },
                        component: resolve => {
                            require(['@/views/project/project/edit.vue'], resolve)
                        }
                    },
                    {
                        path: 'concerts',
                        name: 'project_concerts',
                        meta: {
                            title: '场次管理'
                        },
                        component: resolve => {
                            require(['@/views/project/project/concerts.vue'], resolve)
                        }
                    },
                ]
            },
            {
                path: 'category',
                name: 'project_category_index',
                meta: {
                    title: '分类列表'
                },
                component: resolve => {
                    require(['@/views/project/category/index.vue'], resolve)
                }
            },
            {
                path: 'singer',
                name: 'project_singer_index',
                meta: {
                    title: '艺人列表'
                },
                component: resolve => {
                    require(['@/views/project/singer/index.vue'], resolve)
                }
            },
            {
                path: 'tour',
                name: 'project_tour_index',
                meta: {
                    title: '巡演列表'
                },
                component: resolve => {
                    require(['@/views/project/tour/index.vue'], resolve)
                }
            },
            {
                path: 'registration',
                name: 'project_registration_index',
                meta: {
                    title: '缺货登记'
                },
                component: resolve => {
                    require(['@/views/project/registration/index.vue'], resolve)
                }
            }
        ]
    },
    {
        path: '/order',
        name: 'order',
        redirect: '/order/list',
        meta: {
            title: '订单',
            icon: 'md-list-box'
        },
        component: Main,
        children: [
            {
                path: 'list',
                name: 'order_list',
                redirect: '/order/index',
                meta: {
                    title: '直售订单'
                },
                component: RouterView,
                children: [
                    {
                        path: 'index',
                        name: 'order_index',
                        meta: {
                            title: '直售订单'
                        },
                        component: resolve => {
                            require(['@/views/order/order.vue'], resolve)
                        }
                    },
                    {
                        path: 'detail',
                        name: 'order_detail',
                        component: resolve => {
                            require(['@/views/order/order_detail.vue'], resolve)
                        }
                    }
                ]
            },
            {
                path: 'agent',
                name: 'order_agent',
                redirect: '/order/order_agent',
                meta: {
                    title: '代拍订单'
                },
                component: RouterView,
                children: [
                    {
                        path: 'index',
                        name: 'order_agent_index',
                        component: resolve => {
                            require(['@/views/order/order_agent.vue'], resolve)
                        }
                    },
                    {
                        path: 'detail',
                        name: 'order_agent_detail',
                        component: resolve => {
                            require(['@/views/order/order_agent_detail.vue'], resolve)
                        }
                    }
                ]
            },
            {
                path: 'refund',
                name: 'order_refund',
                meta: {
                    title: '售后列表'
                },
                component: resolve => {
                    require(['@/views/order/refund.vue'], resolve)
                }
            },
            {
                path: 'settle',
                name: 'order_settle',
                meta: {
                    title: '结算管理'
                },
                component: resolve => {
                    require(['@/views/order/settle.vue'], resolve)
                }
            },
            {
                path: 'breach',
                name: 'order_breach',
                meta: {
                    title: '违约管理'
                },
                component: resolve => {
                    require(['@/views/order/breach.vue'], resolve)
                }
            },
            {
                path: 'ticketing',
                name: 'order_ticketing',
                meta: {
                    title: '电子票备票'
                },
                component: resolve => {
                    require(['@/views/order/ticketing.vue'], resolve)
                }
            },
            {
                path: 'delivery',
                name: 'order_delivery',
                meta: {
                    title: '纸质票备票'
                },
                component: resolve => {
                    require(['@/views/order/delivery.vue'], resolve)
                }
            }
        ]
    },
    {
        path: '/partner',
        name: 'partner',
        redirect: '/partner/list',
        meta: {
            title: '商家',
            icon: 'ios-people'
        },
        component: Main,
        children: [
            {
                path: 'list',
                name: 'partner_list',
                meta: {
                    title: '商家列表'
                },
                component: resolve => {
                    require(['@/views/partner/partner.vue'], resolve)
                }
            },
            {
                path: 'sku',
                name: 'partner_sku',
                meta: {
                    title: '挂售列表'
                },
                component: resolve => {
                    require(['@/views/partner/sku.vue'], resolve)
                }
            },
            {
                path: 'balance_withdrawal',
                name: 'partner_balance_withdrawal',
                meta: {
                    title: '余额提现'
                },
                component: resolve => {
                    require(['@/views/partner/balance_withdrawal.vue'], resolve)
                }
            },
            {
                path: 'deposit_withdrawal',
                name: 'partner_deposit_withdrawal',
                meta: {
                    title: '保证金提现'
                },
                component: resolve => {
                    require(['@/views/partner/deposit_withdrawal.vue'], resolve)
                }
            },
            {
                path: 'notice',
                name: 'partner_notice',
                meta: {
                    title: '商家公告'
                },
                component: resolve => {
                    require(['@/views/partner/notice.vue'], resolve)
                }
            },
        ]
    },
    {
        path: '/user',
        name: 'user',
        redirect: '/user/list',
        meta: {
            title: '用户',
            icon: 'ios-contacts'
        },
        component: Main,
        children: [
            {
                path: 'list',
                name: 'user_list',
                meta: {
                    title: '用户列表'
                },
                component: resolve => {
                    require(['@/views/user/list.vue'], resolve)
                }
            },
            {
                path: 'blacklist',
                name: 'user_blacklist',
                meta: {
                    title: '票票岛信用'
                },
                component: resolve => {
                    require(['@/views/user/blacklist.vue'], resolve)
                }
            }
        ]
    },
    {
        path: '/market',
        name: 'market',
        meta: {
            title: '营销',
            icon: 'md-flame'
        },
        redirect: '/market/coupon',
        component: Main,
        children: [
            {
                path: 'coupon',
                name: 'market_coupon',
                redirect: '/market/coupon/index',
                meta: {
                    title: '优惠券'
                },
                component: RouterView,
                children: [
                    {
                        path: 'index',
                        name: 'market_coupon_index',
                        meta: {
                            title: '优惠券'
                        },
                        component: resolve => {
                            require(['@/views/market/coupon/index.vue'], resolve)
                        }
                    },
                    {
                        path: 'edit',
                        name: 'market_coupon_edit',
                        component: resolve => {
                            require(['@/views/market/coupon/edit.vue'], resolve)
                        }
                    }
                ]
            },
            {
                path: 'coupon_send',
                name: 'market_coupon_send',
                redirect: '/market/coupon_send/index',
                meta: {
                    title: '优惠券发放'
                },
                component: RouterView,
                children: [
                    {
                        path: 'index',
                        name: 'market_coupon_send_index',
                        component: resolve => {
                            require(['@/views/market/coupon/send.vue'], resolve)
                        }
                    },
                    {
                        path: 'edit',
                        name: 'market_coupon_send_edit',
                        component: resolve => {
                            require(['@/views/market/coupon/send_edit.vue'], resolve)
                        }
                    }
                ]
            },
            {
                path: 'banner',
                name: 'market_banner',
                redirect: '/market/banner/index',
                meta: {
                    title: '轮播图'
                },
                component: RouterView,
                children: [
                    {
                        path: 'index',
                        name: 'market_banner_index',
                        component: resolve => {
                            require(['@/views/market/banner/index.vue'], resolve)
                        }
                    },
                    {
                        path: 'edit',
                        name: 'market_banner_edit',
                        component: resolve => {
                            require(['@/views/market/banner/edit.vue'], resolve)
                        }
                    }
                ]
            },
            {
                path: 'advert',
                name: 'market_advert',
                meta: {
                    title: '广告管理'
                },
                component: resolve => {
                    require(['@/views/market/advert/index.vue'], resolve)
                }
            },
        ]
    },
    // {
    //     path: '/stat',
    //     name: 'stat',
    //     redirect: '/stat/index',
    //     meta: {
    //         title: '统计',
    //         icon: 'md-stats'
    //     },
    //     component: Main,
    //     children: [
    //         {
    //             path: 'index',
    //             name: 'stat_index',
    //             component: resolve => {
    //                 require(['@/views/stat/index.vue'], resolve)
    //             }
    //         }
    //     ]
    // },
    {
        path: '/settings',
        name: 'settings',
        redirect: '/settings/app',
        meta: {
            title: '设置',
            icon: 'md-settings'
        },
        component: Main,
        children: [
            {
                path: 'index',
                name: 'settings_index',
                meta: {
                    title: '系统设置'
                },
                component: resolve => {
                    require(['@/views/settings/index.vue'], resolve)
                }
            },
            {
                path: 'app',
                name: 'settings_app',
                meta: {
                    title: 'APP管理'
                },
                component: resolve => {
                    require(['@/views/settings/app.vue'], resolve)
                }
            },
            {
                path: 'admin',
                name: 'settings_admin',
                meta: {
                    title: '管理员'
                },
                component: resolve => {
                    require(['@/views/settings/admin.vue'], resolve)
                }
            },
            {
                path: 'role',
                name: 'settings_role',
                meta: {
                    title: '角色管理'
                },
                component: resolve => {
                    require(['@/views/settings/role.vue'], resolve)
                }
            },
            {
                path: 'platform',
                name: 'settings_platform',
                meta: {
                    title: '出票平台'
                },
                component: resolve => {
                    require(['@/views/settings/platform.vue'], resolve)
                }
            },
            {
                path: 'platform_address',
                name: 'settings_platform_address',
                meta: {
                    title: '收票地址'
                },
                component: resolve => {
                    require(['@/views/settings/platform_address.vue'], resolve)
                }
            },
            // {
            //     path: 'notice',
            //     name: 'settings_notice',
            //     meta: {
            //         title: '通知管理'
            //     },
            //     component: resolve => {
            //         require(['@/views/settings/notice.vue'], resolve)
            //     }
            // },
        ]
    },
    // {
    //     path: '/demo',
    //     name: 'demo',
    //     redirect: '/demo/index',
    //     meta: {
    //         hidden: false,
    //         title: 'DEMO',
    //         icon: 'md-cube',
    //         style: {
    //             marginTop: '100px'
    //         }
    //     },
    //     component: Main,
    //     children: [
    //         {
    //             path: 'index',
    //             name: 'demo_index',
    //             component: resolve => {
    //                 require(['@/views/demo/index.vue'], resolve)
    //             }
    //         }
    //     ]
    // }
]

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    ...unLoginRouter,
    ...simpleRouter,
    ...appRouter
];